//
//  ZSVisitorController.swift
//  新浪微博-Swift
//
//  Created by 周李波 on 16/7/19.
//  Copyright © 2016年 q. All rights reserved.
//

import UIKit

class ZSVisitorController: UIViewController {
    //判断登陆
    var isLogin:Bool = false
    //访客视图
    var visitorView:ZSVisitorView?
    //MARK:- 启动时加载界面
    override func loadView() {
        
        isLogin ? (view = tableView) : setupVisitorView()
    }
    
    
    //MARK:- 设置访客视图
    func setupVisitorView(){
        visitorView = ZSVisitorView()
        visitorView!.closure = {
            self.loginClick()
        }
        view = visitorView
        setupNav()
        
    }
    //MARK:- 登陆或者注册按钮点击
    //私有以后要加@objc
    @objc private func loginClick(){
        //加载授权页面
        
        let oauthView:ZSOAuthController = ZSOAuthController()
        presentViewController(UINavigationController(rootViewController: oauthView), animated: true, completion: nil)
     
    }
    //MARK:- 设置导航栏按钮
    func setupNav(){
        navigationItem.leftBarButtonItem = ZSBarButtonItem(title: "登陆", target: self, action: #selector(ZSVisitorController.loginClick))
        navigationItem.rightBarButtonItem = ZSBarButtonItem(title: "注册", target: self, action: #selector(ZSVisitorController.loginClick))
        
    }
    //MARK:- 加载完成
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    //MARK:- 懒加载
    lazy var tableView:UITableView = UITableView()

}
